﻿Imports Oracle.DataAccess.Client
Public Class fListaTipoIva
    Dim lIdTipoIva As String
    Public ReadOnly Property TipoIva() As String
        Get
            Return lIdTipoIva
        End Get
    End Property


    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsulta.Click
        Dim Conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
        Dim cmd As OracleCommand = Conn.CreateCommand
        cmd.CommandText = "SELECT * FROM CON_TIPOIVA "
        Dim qWhere As String = ""
        If Me.txtDescTipoIva.Text.Trim.Length > 0 Then
            qWhere = "WHERE DESCRIPCION LIKE '%" & Me.txtDescTipoIva.Text & "%'"
        End If
        cmd.CommandText &= qWhere
        Try
            Me.DsContabilidad.CON_TIPOIVA.Rows.Clear()
            Conn.Open()
            DsContabilidad.CON_TIPOIVA.Load(cmd.ExecuteReader)
            Conn.Close()
            CON_TIPOIVADataGridView.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub CON_TIPOIVADataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles CON_TIPOIVADataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lIdTipoIva = CON_TIPOIVADataGridView.Rows(e.RowIndex).Cells("IDTIPOIVA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub AsignaTipoIva(ByVal Fila As Integer)
        If Fila >= 0 Then
            lIdTipoIva = CON_TIPOIVADataGridView.Rows(Fila).Cells("IDTIPOIVA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub CON_TIPOIVADataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CON_TIPOIVADataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaTipoIva(CON_TIPOIVADataGridView.CurrentRow.Index)
        End If
    End Sub
End Class